package WaiBao;

import java.util.ArrayList;
import java.util.Arrays;

public class GuoBingNan {
    public static void main(String[] args) {
        String[] name = {"张梦琪(班长)","张雨晴(组织委员)", "小李(学习委员)","张浩凯(文艺委员)", "李贤达", "张关云", "李审议", "张义军", "杨联盟", "李炳", "李杰委", "张志远",
                "张云杰", "李静怡", "张松岭", "李金选", "张云清", "李杰", "李克伟", "利欧豪", "张荣春", "李占国", "张杰红", "李茂选", "李丽媛", "张荣春", "李云清", "张掖送",
                "李温枝", "郭炳南 (学生)"};//考生本人: 郭炳南 (学生)
        int[] age = {19,21,21,20, 18,21, 19, 20, 19, 19, 18, 18, 18, 20, 18, 19, 20, 19, 18, 19, 19, 19, 20, 19, 20, 21, 21,20, 20, 19};//最后一位：考生年龄:19

        double[] tomact1 = {87, 90, 86, 78, 78, 67, 78, 89, 81, 84, 91, 81, 85, 76, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 87, 76, 80, 97};
        double[] tomact2 = {86, 84, 77, 84, 78, 77, 81, 64, 88, 77, 85, 74, 72, 85, 64, 75, 76, 99, 66, 98, 72, 71, 95, 86, 78, 88, 84, 85, 81, 90};
        double[] tomact3 = {87, 77, 83, 85, 75, 69, 78, 69, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 82, 78, 79, 87, 96};


        double fang1;//代表每个学生的总分
        double fang2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            fang1 =tomact1[i] + tomact2[i] + tomact3[i];
//            fang2= (fang1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + fang1);
//            System.out.println(name[i] + "的平均分为:" +fang2);
//        }


        double hundun1 = 0,hundun2 = 0;
        double[] jaiozi = new double[30];
//        for (int i = 0; i < 30; i++) {
//            hundun1=tomact1[i] +tomact2[i] + tomact3[i];
//            hundun2 = (hundun1* 1.0) / 3;
//            jaiozi[i] = hundun2;
//        }
//
//        for (int i = 0; i < jaiozi.length - 1; i++) {
//            for (int j = 0; j <jaiozi.length - i - 1; j++) {
//                if (jaiozi[j] <jaiozi[j + 1]) {
//                    double tep = jaiozi[j];
//                    jaiozi[j] =jaiozi[j + 1];
//                    jaiozi[j + 1] = tep;
//                }
//            }
//        }
//
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(jaiozi[i]);
//        }

        double ysl1 = 0,ysl2 = 0,ysl3 = 0;//计算每门课的平均分
        double bo1 = 0,  bo2 = 0,bo3 = 0;//计算每门课标准差
        double co1 = 0,co2 = 0, co3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < tomact1.length; i++) {
            he += tomact1[i];
        }
        ysl1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +ysl1);
        double Sum = 0;
        for (int i = 0; i < tomact2.length; i++) {
            Sum += tomact2[i];
        }
        ysl2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +ysl2);
        double sum = 0;
        for (int i = 0; i < tomact3.length; i++) {
            sum +=tomact3[i];
        }
        ysl3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + ysl3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < tomact1.length; i++) {
            c1 += (tomact1[i] - ysl1) * (tomact1[i] -ysl1);
        }
        bo1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +bo1);
        for (int i = 0; i <tomact2.length; i++) {
            c2 += (tomact2[i] -ysl2) * (tomact2[i] -ysl2);
        }
        bo2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +bo2);

        for (int i = 0; i <tomact3.length; i++) {
            c3 += (tomact3[i] - ysl3) * (tomact3[i] - ysl3);
        }
        bo3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +bo3);
////////
//        Arrays.sort(tomact1);
//        Arrays.sort(tomact2);
//        Arrays.sort(tomact3);
//        co1 = (tomact1[15] + tomact1[14]) * 1.0 / 2;
//        co2 = (tomact2[15] +tomact2[14]) * 1.0 / 2;
//        co3 = (tomact3[15] +tomact3[14]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  co1);
//        System.out.println("农业设施设计与制造的中位数为:" + co2);
//        System.out.println("园艺植物设施栽培学的中位数为:" + co3);










    }
}
